"""
Run this file to run the game.
"""

####IMPORTS####
import pygame, os
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((0,0), FULLSCREEN)
from qnd import *
from georje import Georje
from box import Box

####CONSTANTS####
FRAMERATE = 60

####FUNCTIONS####
def play_level(level):
	"""Playes the level"""

	#This is kinda crappy code right now. Eventually you will want to
	#have something better here, like loading all of this procedurally
	#from a file. But for now this is where you should put the code to
	#initialize the level.
	
	camera = Camera(screen)
	tilemap = load_tilemap(level+'.map')
	tileset = load_tileset('tileset_1.png','images')
	clock = pygame.time.Clock()
	georje = Georje((100,600))
	
	boxes = []
	for i in range(64):
		boxes.append(Box((i*32,32*24)))
	for i in range(6):
		for j in range(i):
			boxes.append(Box((i*32+32*16,32*(23-i+j))))
	while True:
		
		input.update()
		georje.update(input, boxes)		
		
		draw_tiles(screen, camera, tilemap, tileset)
		for box in boxes:
			box.draw(screen,camera)
			
		georje.draw(screen,camera)
		pygame.display.flip()
		clock.tick(FRAMERATE)

	
####INITIALIZE####
input = InputHandler()
screen.fill((00,240,60))
draw_text(screen, "The Adventures of Georje", ('c','c'),pygame.font.Font(None,140))
pygame.display.flip()
pygame.time.wait(1000)
play_level("level_1")
